package com.aliyun.messagemgt.model;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;

import java.io.Serializable;
import java.util.List;

/**
 * @author Qinyuan
 * @date 2025/7/29
 */
@ToString
@ApiModel("消息推送请求")
public class AsyncPushRequest implements Serializable {

    @ApiModelProperty("租户编码")
    private String tenantCode;

    @ApiModelProperty("密钥")
    private String secretKey;

    @ApiModelProperty("消息列表")
    private List<MsgRecordDTO> msgRecordList;

    @ToString
    @ApiModel("消息记录")
    public static class MsgRecordDTO implements Serializable {

        @ApiModelProperty("源端系统消息ID(源端系统唯一)")
        private String orgMessageId;

        @ApiModelProperty("租户编码")
        private String tenantCode;

        @ApiModelProperty("userId")
        private String userId;

        @ApiModelProperty("场景编码，组件前端维护")
        private String sceneCode;

        @ApiModelProperty("消息信息")
        private MessageInfo messageInfo;

        @ApiModelProperty("接收渠道编码清单(最多10个)")
        private List<String> receiveChannelCodes;

        @ApiModelProperty("接收范围信息")
        private ReceiveRangeInfo receiveRangeInfo;

        @ApiModelProperty("失败重发次数,最小为1,默认不重试")
        private Integer failureResendTimes;

        @ApiModelProperty("失败重发时间间隔,单位：分钟,最小为1,配置失败重发次数后有效")
        private Integer failureResendInterval;

        @ToString
        @ApiModel("消息信息")
        public static class MessageInfo implements Serializable {

            @ApiModelProperty("消息传输类型：CONTENT-传内容，TEMPLATE-传模板，LINK_CARD-卡片链接")
            private String messageTransType;

            @ApiModelProperty("消息内容")
            private String messageContent;

            @ApiModelProperty("链接卡片信息")
            private LinkCard linkCard;

            @ApiModelProperty("消息主题")
            private String messageSubject;

            @ApiModelProperty("消息附件")
            private String messageAttachment;

            @ApiModelProperty("模板编码")
            private String templateCode;

            @ApiModelProperty("模板参数")
            private JSONObject templateParams;

            public String getMessageTransType() {
                return messageTransType;
            }

            public void setMessageTransType(String messageTransType) {
                this.messageTransType = messageTransType;
            }

            public String getMessageContent() {
                return messageContent;
            }

            public void setMessageContent(String messageContent) {
                this.messageContent = messageContent;
            }

            public LinkCard getLinkCard() {
                return linkCard;
            }

            public void setLinkCard(LinkCard linkCard) {
                this.linkCard = linkCard;
            }

            public String getMessageSubject() {
                return messageSubject;
            }

            public void setMessageSubject(String messageSubject) {
                this.messageSubject = messageSubject;
            }

            public String getMessageAttachment() {
                return messageAttachment;
            }

            public void setMessageAttachment(String messageAttachment) {
                this.messageAttachment = messageAttachment;
            }

            public String getTemplateCode() {
                return templateCode;
            }

            public void setTemplateCode(String templateCode) {
                this.templateCode = templateCode;
            }

            public JSONObject getTemplateParams() {
                return templateParams;
            }

            public void setTemplateParams(JSONObject templateParams) {
                this.templateParams = templateParams;
            }
        }

        @ToString
        @ApiModel("消息接收范围信息")
        public static class ReceiveRangeInfo implements Serializable {
            private static final long serialVersionUID = 6213948695707219839L;

            @ApiModelProperty("范围传输方式：GROUP-按分组，CUST-按报文自定义")
            private String rangeTransType;

            @ApiModelProperty("接收组编码清单（最多10个）")
            private List<String> receiveGroupCodes;

            @ApiModelProperty("范围类型：ORG-组织，POS-职位，ROLE-角色，USERID-用户ID，PHONE-用户手机号，EMAIL-用户邮箱")
            private String rangeType;

            @ApiModelProperty("范围值列表：组织ID/职位ID/角色ID/用户ID/手机号/邮箱")
            private List<String> rangeValues;

            public String getRangeTransType() {
                return rangeTransType;
            }

            public void setRangeTransType(String rangeTransType) {
                this.rangeTransType = rangeTransType;
            }

            public List<String> getReceiveGroupCodes() {
                return receiveGroupCodes;
            }

            public void setReceiveGroupCodes(List<String> receiveGroupCodes) {
                this.receiveGroupCodes = receiveGroupCodes;
            }

            public String getRangeType() {
                return rangeType;
            }

            public void setRangeType(String rangeType) {
                this.rangeType = rangeType;
            }

            public List<String> getRangeValues() {
                return rangeValues;
            }

            public void setRangeValues(List<String> rangeValues) {
                this.rangeValues = rangeValues;
            }
        }

        public String getOrgMessageId() {
            return orgMessageId;
        }

        public void setOrgMessageId(String orgMessageId) {
            this.orgMessageId = orgMessageId;
        }

        public String getTenantCode() {
            return tenantCode;
        }

        public void setTenantCode(String tenantCode) {
            this.tenantCode = tenantCode;
        }

        public String getUserId() {
            return userId;
        }

        public void setUserId(String userId) {
            this.userId = userId;
        }

        public String getSceneCode() {
            return sceneCode;
        }

        public void setSceneCode(String sceneCode) {
            this.sceneCode = sceneCode;
        }

        public MessageInfo getMessageInfo() {
            return messageInfo;
        }

        public void setMessageInfo(MessageInfo messageInfo) {
            this.messageInfo = messageInfo;
        }

        public List<String> getReceiveChannelCodes() {
            return receiveChannelCodes;
        }

        public void setReceiveChannelCodes(List<String> receiveChannelCodes) {
            this.receiveChannelCodes = receiveChannelCodes;
        }

        public ReceiveRangeInfo getReceiveRangeInfo() {
            return receiveRangeInfo;
        }

        public void setReceiveRangeInfo(ReceiveRangeInfo receiveRangeInfo) {
            this.receiveRangeInfo = receiveRangeInfo;
        }

        public Integer getFailureResendTimes() {
            return failureResendTimes;
        }

        public void setFailureResendTimes(Integer failureResendTimes) {
            this.failureResendTimes = failureResendTimes;
        }

        public Integer getFailureResendInterval() {
            return failureResendInterval;
        }

        public void setFailureResendInterval(Integer failureResendInterval) {
            this.failureResendInterval = failureResendInterval;
        }
    }

    @ToString
    @ApiModel("卡片消息内容")
    public static class LinkCard implements Serializable {
        private static final long serialVersionUID = -4835772484308194743L;

        @ApiModelProperty("卡片标题")
        private String title;

        @ApiModelProperty("卡片描述")
        private String description;

        @ApiModelProperty("卡片链接")
        private String iconLink;

        @ApiModelProperty("卡片跳转链接")
        private String link;

        @ApiModelProperty("PC端卡片跳转链接")
        private String pcLink;

        private String fromName;

        private String fromIconLink;

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        public String getIconLink() {
            return iconLink;
        }

        public void setIconLink(String iconLink) {
            this.iconLink = iconLink;
        }

        public String getLink() {
            return link;
        }

        public void setLink(String link) {
            this.link = link;
        }

        public String getPcLink() {
            return pcLink;
        }

        public void setPcLink(String pcLink) {
            this.pcLink = pcLink;
        }

        public String getFromName() {
            return fromName;
        }

        public void setFromName(String fromName) {
            this.fromName = fromName;
        }

        public String getFromIconLink() {
            return fromIconLink;
        }

        public void setFromIconLink(String fromIconLink) {
            this.fromIconLink = fromIconLink;
        }
    }

    public String getTenantCode() {
        return tenantCode;
    }

    public void setTenantCode(String tenantCode) {
        this.tenantCode = tenantCode;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public List<MsgRecordDTO> getMsgRecordList() {
        return msgRecordList;
    }

    public void setMsgRecordList(List<MsgRecordDTO> msgRecordList) {
        this.msgRecordList = msgRecordList;
    }
}
